﻿angular.module('iHouse', [])
    .controller('bookController', function ($scope, $http) {
        $scope.books;
        $scope.isAuthenticated = false;
        $scope.currentCategory;
        $scope.currentPage;

        $http.get("/api/BookApi/getall/1").success(function (data, status, headers, config) {
            var bookReviews = [];
            $(data).each(function (i) {
                var book = data[i];
                var detailLink = '/api/BookApi/get/' + book.ID;
                var editLink = '/api/BookApi/edit/' + book.ID;
                var uploadLink = '/api/BookApi/upload/' + book.ID;
                var review = { 'Name': book.Name, 'DetailLink': detailLink, 'EditLink': editLink, 'UploadLink': uploadLink, 'ImagePath': book.ImagePath };

                bookReviews.push(review);
            })
            $scope.books = bookReviews;
        }).error(function (data, status, headers, config) {

        });
    })